<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>

<head>
    <base href="<%=basePath%>"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css" />
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>

<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">编辑名片</h4>
    </div>

    <div class="panel-body">
        <form action="mingpian/insert" id="myform" method="post"
              class="form-horizontal" role="form">
            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="name" class="col-md-4 control-label">姓名</label>
                    <div class="col-md-8">
                        <input type="hidden" id="oid" name="oid" value="">
                        <input type="text" id="name" name="name"
                               class="form-control" placeholder="请输入姓名"
                               value="">
                    </div>
                </div>

                <div class="form-group col-md-6">
                    <label  class="col-md-4 control-label">性别</label>
                    <div class="col-md-8">
                        <label class="radio-inline">
                            <input type="radio" name="sex"  value="F">男
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="sex"  value="M">女
                        </label>
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="typeid" class="col-md-4 control-label">名片夹</label>
                    <div class="col-md-8">
                        <select name="typeid" class="form-control" id="typeid">
                            <option value="">--请选择--</option>
                            <c:forEach items="${type}" var="t">
                            <option value="${t.oid}">${t.type}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="company" class="col-md-4 control-label">公司名称</label>
                    <div class="col-md-8">
                        <input type="text" id="company" name="company" class="form-control"
                               placeholder="请输入公司名称" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="homePhone" class="col-md-4 control-label">家庭电话</label>
                    <div class="col-md-8">
                        <input type="text" id="homePhone" name="homePhone" class="form-control"
                               placeholder="请输入家庭电话" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="officePhone" class="col-md-4 control-label">办公电话</label>
                    <div class="col-md-8">
                        <input type="text" id="officePhone" name="officePhone" class="form-control"
                               placeholder="请输入办公电话" value="">
                    </div>
                </div>
            </div>


            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="homeAddress" class="col-md-4 control-label">家庭地址</label>
                    <div class="col-md-8">
                        <input type="text" id="homeAddress" name="homeAddress" class="form-control"
                               placeholder="请输入家庭地址" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="officeAddress" class="col-md-4 control-label">办公地址</label>
                    <div class="col-md-8">
                        <input type="text" id="officeAddress" name="officeAddress" class="form-control"
                               placeholder="请输入办公地址" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="homeZipcode" class="col-md-4 control-label">家庭邮编</label>
                    <div class="col-md-8">
                        <input type="text" id="homeZipcode" name="homeZipcode" class="form-control"
                               placeholder="请输入家庭邮编" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="officeZipcode" class="col-md-4 control-label">办公邮编</label>
                    <div class="col-md-8">
                        <input type="text" id="officeZipcode" name="officeZipcode" class="form-control"
                               placeholder="请输入办公邮编" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="email1" class="col-md-4 control-label">个人邮箱</label>
                    <div class="col-md-8">
                        <input type="text" id="email1" name="email1" class="form-control"
                               placeholder="请输入个人邮箱" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="email2" class="col-md-4 control-label">办公邮箱</label>
                    <div class="col-md-8">
                        <input type="text" id="email2" name="email2" class="form-control"
                               placeholder="请输入办公邮箱" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label  class="col-md-4 control-label">其它信息</label>
                    <div class="col-md-8">
							<textarea class="form-control" id="description"
                                      name="other" rows="5" placeholder="请输入其它补充信息"></textarea>
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="mobile" class="col-md-4 control-label">个人电话</label>
                    <div class="col-md-8">
                        <input type="text" id="mobile" name="mobile" class="form-control"
                               placeholder="请输入个人电话" value="">
                    </div>
                </div>
            </div>


            <div class="col-md-12">
                <div class="form-group col-md-12">
                    <div class="col-md-10  col-md-offset-2">
                        <a type="button" href="javascript:history.back()" class="btn btn-info">返回</a>
                        <button type="submit" id="editContactBtn" class="btn btn-success">提交信息</button>
                        <button type="reset" id="resetbtn" class="btn btn-default">取消操作</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>







<script type="text/javascript">
    $(document).ajaxError(function(event,xhr) {
        if(xhr.status=="403"){//没有权限
            document.location.href = xhr.getResponseHeader("url");
        }else if(xhr.status!="200"){
            //alert("服务器错误!");
            console.log("服务器错误!");
        }
    });
</script>

</body>


<script type="text/javascript">
    $(document).ready(function() {
        $("#myform").bootstrapValidator({
            message : 'This value is not valid',
            feedbackIcons : {/*input状态样式图片*/
                valid : 'glyphicon glyphicon-ok',
                invalid : 'glyphicon glyphicon-remove',
                validating : 'glyphicon glyphicon-refresh'
            },
            fields : {
                name : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '姓名不能为空'

                        },
                        stringLength : {
                            min : 2,
                            max : 20,
                            message : '姓名长度需在2-20位'
                        }
                    }
                },
                sex : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '请选择性别'
                        }
                    }
                },
                typeid : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '请选择所属名片夹'
                        }
                    }
                },
                company : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '公司名称不能为空'

                        },
                        stringLength : {
                            min : 2,
                            max : 20,
                            message : '公司名称长度需在2-20位'
                        }
                    }
                },
                homePhone : {
                    validators : {
                        regexp : {
                            regexp : /^(^(\d{3,4}-)?\d{7,8})$|^((1[0-9][0-9]\d{8}$))$/,
                            message : '电话格式不正确'
                        }
                    }
                },
                officePhone : {
                    validators : {
                        regexp : {
                            regexp : /^(^(\d{3,4}-)?\d{7,8})$|^((1[0-9][0-9]\d{8}$))$/,
                            message : '电话格式不正确'
                        }
                    }
                },
                mobile : {
                    validators : {
                        regexp : {
                            regexp : /^(^(\d{3,4}-)?\d{7,8})$|^((1[0-9][0-9]\d{8}$))$/,
                            message : '电话格式不正确'
                        }
                    }
                },
                email1 : {
                    validators : {
                        emailAddress : {
                            message : 'E-mail格式不正确'
                        }
                    }
                },
                email2 : {
                    validators : {
                        emailAddress : {
                            message : 'E-mail格式不正确'
                        }
                    }
                },
                homeZipcode : {
                    validators : {
                        regexp : {
                            regexp : /^[1-9]\d{5}$/,
                            message : '邮编格式不正确'
                        }
                    }
                },
                officeZipcode : {
                    validators : {
                        regexp : {
                            regexp : /^[1-9]\d{5}$/,
                            message : '邮编格式不正确'
                        }
                    }
                },
                homeAddress : {
                    validators : {
                        stringLength : {
                            max : 50,
                            message : '信息输入过长'
                        }
                    }
                }
                ,
                officeAddress : {
                    validators : {
                        stringLength : {
                            max : 50,
                            message : '信息输入过长'
                        }
                    }
                },
                other : {
                    validators : {
                        stringLength : {
                            max : 200,
                            message : '信息输入过长'
                        }
                    }
                }
            },
            submitHandler : function(validator,form, submitButton) {
                validator.defaultSubmit();
            }
        });


        $("#resetbtn").click(function() {
            $("#myform").data("bootstrapValidator").resetForm();
        });
    });



</script>
</html>
